﻿using System.Net;
using System.Windows;
using System.Windows.Threading;
using MouseExtender.Logic.Common;

namespace MouseExtender
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        #region properties

        public static MainWindow MainWindowInstance
        {
            get
            {
                return (MainWindow)Application.Current.MainWindow;
            }
        }

        public static Dispatcher UIContext { get; set; }

        #endregion

        #region contructor

        public App()
        {
        }

        #endregion

        #region event handlers

        private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            Logger.HandleCriticalError(e.Exception);
            e.Handled = true;
        }

        #endregion

        #region methods

        public void Activate()
        {
            // Reactivate application's main window
            MainWindow.Show();
            MainWindow.Activate();
        }

        #endregion
    }
}
